<%@page import="java.sql.ResultSet"%>
<%@page import="database.DBConnector"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <link rel="stylesheet" type="text/css" href="../CSS/frontend.css"/>
        <script type="text/javascript" src="../NewCustomer/newcustomerform_ajax.js"></script>
        <%
                    session.setAttribute("VALID_TLF", "FALSE");
                    session.setAttribute("VALID_FNAME", "FALSE");
                    session.setAttribute("VALID_LNAME", "FALSE");
                    session.setAttribute("VALID_STREETNAME", "FALSE");
                    session.setAttribute("VALID_STREETNUMBER", "FALSE");
                    session.setAttribute("VALID_ZIPCODE", "FALSE");
                    session.setAttribute("VALID_CITY", "FALSE");
                    session.setAttribute("VALID_COUNTRY", "FALSE");
        %>
        <title> Firstmile - Reservedele til din klassiker</title>
    </head>
    <body>
        <div id="main">
            <jsp:include page="topBar.jsp"></jsp:include>
            <div id="content">
                <form action="../NewCustomer/validateNewCustomer.jsp" method="post" >
                    <br><br>
                    <table align="center" style="text-align: left;" >
                        <tr>
                            <td style="width: 200px;">Telefonnummer(Login ID):</td>
                            <td><input name="tlf" id="tlf" type="text" maxlength="8" size="29px" onchange="validateTlf(this.value)"/></td>
                            <td><div id="valid_tlf">*</div></td>
                        </tr>
                        <tr>
                            <td>Kodeord:</td>
                            <td><input name="pw1" id="pw1" type="password" maxlength="50" size="29px" onchange="validatePW1(this.value)"/></td>
                            <td><div id="valid_pw1">*</div></td>
                        </tr>
                        <tr>
                            <td>Gentag Kodeord:</td>
                            <td><input name="pw2" id="pw2" type="password" maxlength="50"size="29px" onchange="validatePW2(this.value)"/></td>
                            <td><div id="valid_pw2">*</div></td>
                        </tr>
                        <tr>
                            <td>Fornavn:</td>
                            <td><input name="fname" id="fname" type="text" maxlength="50" size="29px" onchange="validateFname(this.value)"/></td>
                            <td><div id="valid_fname">*</div></td>
                        </tr>
                        <tr>
                            <td>Efternavn:</td>
                            <td><input name="lname" id="lname" type="text" maxlength="50" size="29px" onchange="validateLname(this.value)"/></td>
                            <td><div id="valid_lname">*</div></td>
                        </tr>
                        <tr>
                            <td>E-mail:</td>
                            <td><input name="email" id="email" type="text" maxlength="50" size="29px" /></td>

                        </tr>
                        <tr>
                            <td>Vejnavn:</td>
                            <td><input name="streetname" id="streetname" type="text" maxlength="50" size="29px" onchange="validateStreetname(this.value)"/></td>
                            <td><div id="valid_streetname">*</div><td>
                        </tr>
                        <tr>
                            <td>Husnummer:</td>
                            <td><input name="streetnumber" id="streetnumber" type="text" maxlength="50" size="29px" onchange="validateStreetnumber(this.value)"/></td>
                            <td><div id="valid_streetnumber">*</div></td>
                        </tr>
                        <tr>
                            <td>Postnummer:</td>
                            <td><input name="zipcode" id="zipcode" type="text" maxlength="4" size="29px" onchange="validateZipcode(this.value)"/></td>
                            <td><div id="valid_zipcode">*</div></td>
                        </tr>
                        <tr>
                            <td>By:</td>
                            <td><input name="city" id="city" type="text" maxlength="50" size="29px" onchange="validateCity(this.value)"/></td>
                            <td><div id="valid_city">*</div></td>
                        </tr>
                        <tr>
                            <td> Land:</td>
                            <td><SELECT name="country" id="country" onchange="validateCountry(this.value)">
                                    <%DBConnector dbc = DBConnector.getDBC();
                                                ResultSet rs = dbc.doQuery("SELECT * FROM Countries ORDER BY CountryName");
                                                while (rs.next()) {
                                                    out.println("<option>" + rs.getString(1) + "</option>");
                                                }
                                    %>
                                </SELECT></td>
                            <td><div id="valid_country">*</div></td>
                        </tr>
                        <tr>
                            <td><div id="captcha"><img alt="" src="../NewCustomer/captcha.jsp"></div></td>
                            <td><input name="captchaInput" id="captchaInput" type="text" size="29px"><br>
                                <input name="refresh" id="refresh" type="button" size="20px" value="WHAT? Nyt billede tak" onclick="refreshCaptcha()"/></td>
                            <td><div id="valid_captcha">*</div></td>
                        </tr>
                        <%--
                        <tr>
                            <td>CVR:</td>
                            <td><input id="cvr" type="text" maxlength="50" size="30px" onblur="validateCVR(this.value)"/></td>
                            <td><div id="valid_"></div><td>
                        </tr>
                        <tr>
                            <td>Firma:</td>
                            <td><input id="company" type="text" maxlength="50" size="30px" onblur="validateCompany(this.value)"/></td>
                            <td><div id="valid_company"></div><td>
                        </tr>
                        --%>
                        <tr>
                            <td><input type="submit" value="Opret Bruger"/></td>
                        </tr>
                    </table>
                </form>
            </div>
            <jsp:include page="footNote.jsp"></jsp:include>
        </div>
    </body>
</html>
